home *** CD-ROM | disk | FTP | other *** search
/ Interactive CD-ROM & Web Magazine 6 / Interactive CD-ROM & Web Magazine 6.iso / mac / INTERACTIVE MAC / SHARED.DIR / 05113_textMenu.ls < prev    next >
Encoding:
Text File  |  1996-04-05  |  6.1 KB  |  202 lines

  1. property xOrigin, yOrigin, xExtent, yExtent, myHeight, mySpriteNum, myCastNumber, myLines, myConfigFile, myFileOffset, myFileSpan, myConfigText, myLevel, myTileSpriteNum, tileXOrigin, tileYOrigin, myTileCastNum, myFontAspectRatio, myTileWidth, myTextVOffset, myTrunk
  2. global menuList, workingdb, NetscapePathMac, hd
  3.  
  4. on birth me, theSpriteNum, theHeight, theConfigFile, theFileOffset, theFileSpan, theLevel, theTileSprite, theFontRatio, theTileWidth, theTextVOffset, theTrunk
  5.   set myLevel to theLevel
  6.   set mySpriteNum to theSpriteNum
  7.   set myCastNumber to the castNum of sprite mySpriteNum
  8.   set myTileSpriteNum to theTileSprite
  9.   set myTileCastNum to the castNum of sprite myTileSpriteNum
  10.   set myFontAspectRatio to theFontRatio
  11.   set myTileWidth to theTileWidth
  12.   set myTextVOffset to theTextVOffset
  13.   set myTrunk to theTrunk
  14.   set xExtent to 10
  15.   set myHeight to theHeight
  16.   set myConfigFile to theConfigFile
  17.   resetValues(me, theFileOffset, theFileSpan)
  18.   hideObject(me)
  19.   return me
  20. end
  21.  
  22. on resetValues me, theFileOffset, theFileSpan
  23.   set myFileOffset to theFileOffset
  24.   set myFileSpan to theFileSpan
  25.   set myConfigText to EMPTY
  26.   decodeConfigFile(me)
  27. end
  28.  
  29. on decodeConfigFile me
  30.   if myConfigText = EMPTY then
  31.     set the itemDelimiter to TAB
  32.     set Obj to FileIO(mnew, "read", the pathName & myConfigFile)
  33.     if not objectp(Obj) then
  34.       alert("no oggetto" & Obj)
  35.     end if
  36.     set myConfigText to Obj(mReadFile)
  37.     Obj(mdispose)
  38.   end if
  39.   set the text of cast myCastNumber to EMPTY
  40.   repeat with a = 1 to myFileSpan
  41.     put item 1 of line a + myFileOffset - 1 of myConfigText & RETURN after line a of field myCastNumber
  42.   end repeat
  43.   put line 1 to the number of lines in field myCastNumber - 1 of field myCastNumber into field myCastNumber
  44. end
  45.  
  46. on verticalSynch me
  47.   set the textHeight of field myCastNumber to myHeight
  48.   set yExtent to (the number of lines in field myCastNumber * myHeight) - myTrunk
  49. end
  50.  
  51. on horizontalSynch me
  52.   tileSynch(me)
  53.   set xExtent to integer(findMaxCharsInLine() * the textSize of field myCastNumber * myFontAspectRatio)
  54. end
  55.  
  56. on tileSynch me
  57.   set tileXOrigin to ((xOrigin / myTileWidth) + 1) * myTileWidth
  58.   set xOrigin to tileXOrigin + myTileWidth
  59.   set tileYOrigin to yOrigin / myHeight * myHeight
  60.   set yOrigin to tileYOrigin + myTextVOffset
  61. end
  62.  
  63. on findMaxCharsInLine me
  64.   set maxChar to 0
  65.   repeat with a = 1 to the number of lines in field myCastNumber
  66.     set curChar to the number of chars in line a of field myCastNumber
  67.     if curChar > maxChar then
  68.       set maxChar to curChar
  69.     end if
  70.   end repeat
  71.   return maxChar
  72. end
  73.  
  74. on recalcObject me
  75.   verticalSynch(me)
  76.   horizontalSynch(me)
  77. end
  78.  
  79. on showObject me
  80.   showTile(me)
  81.   set the rect of cast myCastNumber to rect(xOrigin, yOrigin, xOrigin + xExtent, yOrigin + yExtent)
  82.   set the locH of sprite mySpriteNum to xOrigin
  83.   set the locV of sprite mySpriteNum to yOrigin
  84.   updateStage()
  85. end
  86.  
  87. on hideTile
  88.   set the locH of sprite myTileSpriteNum to 1400
  89.   set the locV of sprite myTileSpriteNum to 1400
  90. end
  91.  
  92. on hideObject me
  93.   hideTile(me)
  94.   set the locH of sprite mySpriteNum to 1400
  95.   set the locV of sprite mySpriteNum to 1400
  96.   updateStage()
  97. end
  98.  
  99. on showTile me
  100.   spriteBox(myTileSpriteNum, tileXOrigin, tileYOrigin, tileXOrigin + myTileWidth, tileYOrigin + yExtent)
  101. end
  102.  
  103. on positionObject me, xPos, yPos
  104.   decodeConfigFile(me)
  105.   puppetSprite(mySpriteNum, 1)
  106.   puppetSprite(myTileSpriteNum, 1)
  107.   set xOrigin to xPos
  108.   set yOrigin to yPos
  109.   recalcObject(me)
  110.   showObject(me)
  111. end
  112.  
  113. on hideRight me
  114.   repeat with a = myLevel + 1 to count(menuList)
  115.     hideObject(getAt(menuList, a))
  116.   end repeat
  117. end
  118.  
  119. on showChild me, theLineNumber
  120.   set nextOffset to item 2 of line myFileOffset + theLineNumber - 1 of myConfigText
  121.   if nextOffset = 0 then
  122.     giacomo(me, theLineNumber)
  123.   else
  124.     set nextObj to getAt(menuList, myLevel + 1)
  125.     set nextSpan to item 3 of line myFileOffset + theLineNumber - 1 of myConfigText
  126.     set nextX to xOrigin + xExtent
  127.     set nextY to yOrigin + ((theLineNumber - 1) * myHeight)
  128.     resetValues(nextObj, nextOffset, nextSpan)
  129.     positionObject(nextObj, nextX, nextY)
  130.   end if
  131. end
  132.  
  133. on clickedObject me, theLineNumber
  134.   hideRight(me)
  135.   showChild(me, theLineNumber)
  136. end
  137.  
  138. on giacomo me, theLineNumber
  139.   if the machineType = 256 then
  140.     set root to char 1 to 2 of the pathName
  141.     set pathSeparator to "\"
  142.   else
  143.     set pathSeparator to ":"
  144.     set root to char 1 to 5 of the pathName
  145.   end if
  146.   set folderName to item 6 of line myFileOffset + theLineNumber - 1 of myConfigText
  147.   set subType to item 5 of line myFileOffset + theLineNumber - 1 of myConfigText
  148.   put "subType " & subType
  149.   set target to root & pathSeparator & "IMM" & pathSeparator
  150.   if subType = "DB" then
  151.     set target to target & subType & pathSeparator & subType
  152.     set workingdb to value(item 3 of line myFileOffset + theLineNumber - 1 of myConfigText)
  153.     go(1, target)
  154.   else
  155.     if subType = "DN" then
  156.       set target to target & subType & pathSeparator & folderName & pathSeparator & "index.htm"
  157.       nonloso(me, target)
  158.     else
  159.       if char 1 to 2 of subType = "Mv" then
  160.         set target to target & "mv" & pathSeparator & folderName & pathSeparator & subType
  161.         go(1, target)
  162.       else
  163.         set target to target & subType & pathSeparator & folderName & pathSeparator & subType
  164.         go(1, target)
  165.       end if
  166.     end if
  167.   end if
  168. end
  169.  
  170. on nonloso me, target
  171.   if the machineType = 256 then
  172.     OpenDN(target)
  173.   else
  174.     set obj1 to FileIO(mnew, "read", hd & "IMM.ini")
  175.     if not objectp(obj1) then
  176.       set temp to "none"
  177.     else
  178.       set temp to obj1(mReadFile)
  179.       put temp & "temp"
  180.       put obj1(mdispose)
  181.     end if
  182.     if line 1 of temp = "none" then
  183.       alert("Per favore trova il tuo Browser HTML")
  184.       set obj2 to FileIO(mnew, "?read", "APPL")
  185.       if not objectp(obj2) then
  186.         alert("hai scelto di non configurare un browser HTML")
  187.         return 
  188.       end if
  189.       set netscapeMacPath to obj2(mFileName)
  190.       set obj3 to FileIO(mnew, "write", hd & "IMM.ini")
  191.       put obj3(mWriteString, netscapeMacPath)
  192.       put obj2(mdispose)
  193.       put obj3(mdispose)
  194.     else
  195.       set netscapeMacPath to temp
  196.     end if
  197.     put target
  198.     put netscapeMacPath
  199.     open(target, netscapeMacPath)
  200.   end if
  201. end
  202.